package com.party.core.service.commune.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.commune.CDataAnalysisDetailReadDao;
import com.party.core.dao.write.commune.CDataAnalysisDetailWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.commune.CDataAnalysisDetail;
import com.party.core.model.commune.CDataAnalysisDetailOutput;
import com.party.core.service.commune.ICDataAnalysisDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Service
public class CDataAnalysisDetailService implements ICDataAnalysisDetailService {

    @Autowired
    private CDataAnalysisDetailWriteDao cDataAnalysisDetailWriteDao;
    @Autowired
    private CDataAnalysisDetailReadDao cDataAnalysisDetailReadDao;

    @Override
    public String insert(CDataAnalysisDetail cDataAnalysisDetail) {
        BaseModel.preInsert(cDataAnalysisDetail);
        boolean result = cDataAnalysisDetailWriteDao.insert(cDataAnalysisDetail);
        if (result) {
            return cDataAnalysisDetail.getId();
        }
        return null;
    }

    @Override
    public boolean update(CDataAnalysisDetail cDataAnalysisDetail) {
        cDataAnalysisDetail.setUpdateDate(new Date());
        return cDataAnalysisDetailWriteDao.update(cDataAnalysisDetail);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return cDataAnalysisDetailWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public CDataAnalysisDetail get(String id) {
        return cDataAnalysisDetailReadDao.get(id);
    }

    @Override
    public List<CDataAnalysisDetail> listPage(CDataAnalysisDetail cDataAnalysisDetail, Page page) {
        return cDataAnalysisDetailReadDao.listPage(cDataAnalysisDetail, page);
    }

    @Override
    public List<CDataAnalysisDetail> list(CDataAnalysisDetail cDataAnalysisDetail) {
        return cDataAnalysisDetailReadDao.listPage(cDataAnalysisDetail, null);
    }

    @Override
    public List<CDataAnalysisDetail> batchList(Set<String> ids, CDataAnalysisDetail cDataAnalysisDetail, Page page) {
        return null;
    }

    @Override
    public CDataAnalysisDetail getCDataAnalysisDetailByMemberGroupId(String memberGroupId, Map<String, Object> params) {
        return cDataAnalysisDetailReadDao.getCDataAnalysisDetailByMemberGroupId(memberGroupId, params);
    }

    @Override
    public CDataAnalysisDetailOutput sumOrg(Map<String, Object> params) {
        return cDataAnalysisDetailReadDao.sumOrg(params);
    }

    @Override
    public List<CDataAnalysisDetailOutput> sumOrgList(Map<String, Object> params) {
        return cDataAnalysisDetailReadDao.sumOrgList(params);
    }
}
